package cn.xx.service;

import cn.xx.error.BusinessException;
import cn.xx.service.model.ItemModel;

import java.util.List;

/**
 * @author xiexu
 * @create 2022-04-21 10:58
 */
public interface ItemService {

    // 创建商品
    ItemModel createItem(ItemModel itemModel) throws BusinessException;

    // 商品列表浏览
    List<ItemModel> listItem();

    // 商品详情浏览
    ItemModel getItemById(Integer id);

    // 验证item mode及promo mode缓存模型是否有效
    ItemModel getItemByIdInCache(Integer id);

    // redis库存扣减
    boolean decreaseStock(Integer itemId, Integer amount) throws BusinessException;

    // redis库存回补
    boolean increaseStock(Integer itemId, Integer amount) throws BusinessException;

    // 异步更新库存
    boolean asyncDecreaseStock(Integer itemId, Integer amount);

    // 商品销量增加
    void increaseSales(Integer itemId, Integer amount) throws BusinessException;

    // 初始化库存流水
    String initStockLog(Integer itemId, Integer amount);

}
